package com.struts.deal.corpor.manage.infomanage;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.base.BaseLog;
import com.base.Constants;
import com.ibatis.po.corpor.TCorporation;
import com.ibatis.po.corpor.TIssueposition;
import com.ibatis.po.corpor.TIssuepositionExample;
import com.ibatis.po.corpor.TKindofcorporation;
import com.ibatis.po.system.TCiyt;
import com.ibatis.po.user.TStation;
import com.ibatis.po.user.TSubStation;
import com.ibatis.po.user.TUserInfo;
import com.ibatis.po.user.TVocation;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CDBManager;
import com.lg.system.CSqlMap;
import com.lg.system.CTurnPage;
import com.lg.system.Common;
import com.lg.system.MessageBean;
import com.struts.web.corpor.manage.infomanage.AddPoForm;
import com.struts.web.corpor.manage.infomanage.EditInfoForm;
import com.struts.web.corpor.manage.infomanage.IssuePoForm;
import com.struts.web.corpor.manage.infomanage.PositionBean;
import com.struts.web.corpor.manage.infomanage.ViewApplyBoothForm;
import com.struts.web.corpor.manage.infomanage.ViewCorporInfoBean;
import com.struts.web.corpor.manage.infomanage.ViewCorporInfoForm;
import com.struts.web.manage.admin.station.AddSubStaForm;
import com.struts.web.user.register.RegUserInfoForm;

public class InfoDeal {


	/**
	 * 删除指定的职位
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean delPosition(HttpServletRequest request,
			HttpServletResponse response,IssuePoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TIssuepositionExample positionEp = new TIssuepositionExample();
		try{
			String positionId = request.getParameter("positionId");
			positionEp.createCriteria().andIdEqualTo(positionId);
			int count = (Integer)sqlmap.delete("T_ISSUEPOSITION.abatorgenerated_deleteByExample", positionEp);
			if(count>0){
				BaseLog.logger.info("delsuccess");
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 删除所有职位
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean delAllPosition(HttpServletRequest request,
			HttpServletResponse response,IssuePoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		int count = 0;
		TIssuepositionExample positionEp = new TIssuepositionExample();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		try{
			if(corpor!=null){
				String coporId = corpor.getId();
				positionEp.createCriteria().andCORPORATIONEqualTo(coporId);
				count = (Integer)sqlmap.delete("T_ISSUEPOSITION.abatorgenerated_deleteByExample", positionEp);
				if(count>0){
					result=true;
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 加载职位列表
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean loadPositionList(HttpServletRequest request,
			HttpServletResponse response,IssuePoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		TIssuepositionExample positionEp = new TIssuepositionExample();
		List positionList = null;
		ArrayList<PositionBean> poBeanList = new ArrayList<PositionBean>();

		TIssueposition issuePoBean = new TIssueposition(); 
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		try{
			if(corpor!=null){
				positionEp.createCriteria().andCORPORATIONEqualTo(corpor.getId());
				positionEp.setOrderByClause(" ISSUETIME desc ");
				positionList = sqlmap.queryForList("T_ISSUEPOSITION.abatorgenerated_selectByExample",positionEp);
				for(int i=0;i<positionList.size();i++){
					PositionBean poBean = new PositionBean();
					issuePoBean = (TIssueposition)positionList.get(i);
					poBean.setPositionId(issuePoBean.getId());
					poBean.setPositionName(issuePoBean.getPOSITION());
					poBean.setIssueTime(format.format(issuePoBean.getSTARTISSUEDATE()));
					poBeanList.add(poBean);
				}
				aWebForm.setPositionList(poBeanList);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}


	/**
	 * 新增职位
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean addPosition(HttpServletRequest request,
			HttpServletResponse response,AddPoForm aWebForm) throws SQLException{
		boolean result = false;
		String temp = "";
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		TIssueposition positionPo = new TIssueposition();
		try{
			if(corpor!=null){
				positionPo.setId(Common.getNewID());
				positionPo.setCORPORATION(corpor.getId());
				positionPo.setPOSITION(aWebForm.getPositionName());
				positionPo.setGWLBBH(aWebForm.getStations());
				temp=addSubSta(aWebForm.getStations(),aWebForm.getSubStation());
				
				positionPo.setGANGWEITYPE(temp);
				positionPo.setREQUIREMENT(aWebForm.getRequirement());
				positionPo.setPositionDescript(aWebForm.getDescript());
				positionPo.setSTARTISSUEDATE(Date.valueOf(aWebForm.getStartIssueDate()));
				positionPo.setENDISSUEDATE(Date.valueOf(aWebForm.getEndIssueDate()));

				
				sqlmap.insert("T_ISSUEPOSITION.abatorgenerated_insert", positionPo);
				
				
				result = true;
				
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	
	public static String addSubSta(String stations,String substation) throws SQLException{
		String  substaid = "";
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TSubStation subStaPo = new TSubStation();
		int count = 0;
		String subStaName = substation;
		try{

			if(subStaName!=null && subStaName!=""){
				count = ((Integer)sqlmap.queryForObject("T_SUB_STATION.selectIsExist",subStaName)).intValue();
				if(count<1){
					subStaPo.setId(Common.getNewID());
					subStaPo.setPostName(subStaName);
					subStaPo.setSortId(stations);
					subStaPo.setStatus("1");

					sqlmap.insert("T_SUB_STATION.insertBySortId",subStaPo);
					
					substaid = subStaPo.getId();
				}
			}else {
				substaid=(String)sqlmap.queryForObject("T_SUB_STATION.selectIsExist",subStaName);
			}

		}catch(Exception e){
			e.printStackTrace();
		}
		return substaid;
	}
	
	
	/**
	 * 加载新增职位页面信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static MessageBean loadAddPosition(HttpServletRequest request,
			HttpServletResponse response,AddPoForm aWebForm) throws SQLException{
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TStation stationPo = new TStation();
		List stationList = null;
		String str="";
		String sKey="";
		String sValue="";
		int count=0;
		MessageBean messageBean = new MessageBean();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		try{
			//验证企业是否被批准
			count = (Integer)sqlmap.queryForObject("T_CORPORATION.selectIsApproveByID",corpor);
			if(count>0){
				messageBean.setMessage(Constants.NOT_APPROVE);
				return messageBean;
			}

			//岗位列表
			stationList = sqlmap.queryForList("T_STATION.selectAllSubNotNull");
			str += "var station=new Array('','－－请选择岗位－－'";
			for(int i=0;i<stationList.size();i++){
				stationPo = (TStation)stationList.get(i);
				sKey = stationPo.getId();
				sValue = stationPo.getSortName();
				str += ",'" + sKey + "',"; 
				str += "'" + sValue + "'\n";
			}
			str += ");\n";
			aWebForm.setPrintStaSql(str); 
			messageBean.setResult(true);
		}catch(Exception e){
			e.printStackTrace();
		}
		return messageBean;
	}

	/**
	 * 加载修改页面信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean loadEditPosition(HttpServletRequest request,
			HttpServletResponse response,AddPoForm aWebForm) throws SQLException{
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		boolean result = false;
		TStation stationPo = new TStation();
		TSubStation substationPo = new TSubStation();
		TIssueposition positionPo = new TIssueposition();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String positionId = "";
		if(request.getParameter("positionId").trim()!=null && request.getParameter("positionId").trim()!=""){
			positionId = request.getParameter("positionId");
		}
		List stationList = null;
		List subStationList = null;
		String str="";
		String str2="";
		String sKey="";
		String sValue="";
		try{
			if(positionId!=""){
				positionPo.setId(positionId);

				//设置职位信息
				positionPo = (TIssueposition)sqlmap.queryForObject("T_ISSUEPOSITION.abatorgenerated_selectByPrimaryKey",positionPo);

				request.setAttribute("station", positionPo.getGWLBBH());
				request.setAttribute("subStation", positionPo.getGANGWEITYPE());
				System.out.println(positionPo.getGWLBBH()+"--"+ positionPo.getGANGWEITYPE());
				aWebForm.setPositionName(positionPo.getPOSITION());
				aWebForm.setDescript(positionPo.getPositionDescript());
				aWebForm.setRequirement(positionPo.getREQUIREMENT());
				aWebForm.setStartIssueDate(format.format(positionPo.getSTARTISSUEDATE()));
				aWebForm.setEndIssueDate(format.format(positionPo.getENDISSUEDATE()));

				//查找岗位
				String sortId = positionPo.getGWLBBH();

				subStationList = sqlmap.queryForList("T_SUB_STATION.selectBySortId",sortId);
				str2 += "var  subStation = new Array(";
				for(int i=0;i<subStationList.size();i++){
					substationPo = (TSubStation)subStationList.get(i);
					sKey = substationPo.getId();
					sValue = substationPo.getPostName();
					if(i==0){
						str2 += "'" + sKey + "',"; 
						str2 += "'" + sValue + "'\n";   
					}else{
						str2 += ",'" + sKey + "',"; 
						str2 += "'" + sValue + "'\n";
					}
				}
				str2 += ");\n";

				//岗位列表
				stationList = sqlmap.queryForList("T_STATION.selectAll");
				str += "var station=new Array('','－－请选择岗位－－'";
				for(int i=0;i<stationList.size();i++){
					stationPo = (TStation)stationList.get(i);
					sKey = stationPo.getId();
					sValue = stationPo.getSortName();
					str += ",'" + sKey + "',"; 
					str += "'" + sValue + "'\n";
				}
				str += ");\n";
				aWebForm.setPrintStaSql(str); 
				aWebForm.setPrintSubStaSql(str2);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 修改职位
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean editPosition(HttpServletRequest request,
			HttpServletResponse response,AddPoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		String positionId = "";
		positionId = request.getParameter("positionId");
		TIssueposition positionPo = new TIssueposition();

		try{
			if(positionId!=""){
				positionPo.setId(positionId);
				positionPo.setPOSITION(aWebForm.getPositionName());
				positionPo.setGWLBBH(aWebForm.getStations());
				positionPo.setGANGWEITYPE(aWebForm.getSubStation());
				positionPo.setREQUIREMENT(aWebForm.getRequirement());
				positionPo.setPositionDescript(aWebForm.getDescript());
				positionPo.setSTARTISSUEDATE(Date.valueOf(aWebForm.getStartIssueDate()));
				positionPo.setENDISSUEDATE(Date.valueOf(aWebForm.getEndIssueDate()));

				int tag = sqlmap.update("T_ISSUEPOSITION.updateById", positionPo);
				if(tag>0){
					result = true;
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 浏览职位
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean viewPosition(HttpServletRequest request,
			HttpServletResponse response,AddPoForm aWebForm) throws SQLException{
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		boolean result = false;
		TIssueposition positionPo = new TIssueposition();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String positionId = "";
		if(request.getParameter("positionId").trim()!=null && request.getParameter("positionId").trim()!=""){
			positionId = request.getParameter("positionId");
		}
		try{
			if(positionId!=""){
				positionPo.setId(positionId);

				//设置职位信息
				positionPo = (TIssueposition)sqlmap.queryForObject("T_ISSUEPOSITION.abatorgenerated_selectByPrimaryKey",positionPo);

				if(positionPo!=null){
					aWebForm.setPositionName(positionPo.getPOSITION());
					aWebForm.setDescript(positionPo.getPositionDescript());
					aWebForm.setRequirement(positionPo.getREQUIREMENT());
					aWebForm.setStartIssueDate(format.format(positionPo.getSTARTISSUEDATE()));
					aWebForm.setEndIssueDate(format.format(positionPo.getENDISSUEDATE()));

					result = true;
				}
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 加载企业信息
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean loadInfo(HttpServletRequest request,
			HttpServletResponse response,EditInfoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");

		String str="";
		String str2="";
		String str3="";
		String sKey="";
		String sValue="";
		List cityList=null;
		List vocationList=null;
		List kindList=null;
		TCiyt cityPo = new TCiyt();
		TVocation vocationPo = new TVocation();
		TKindofcorporation kindPo = new TKindofcorporation();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		try{
			if(corpor != null){
				corpor = (TCorporation)sqlmap.queryForObject("T_CORPORATION.abatorgenerated_selectByPrimaryKey",corpor);
				aWebForm.getCorporPo().setContactPerson(corpor.getContactPerson());
				aWebForm.getCorporPo().setContactAddress(corpor.getContactAddress());
				aWebForm.getCorporPo().setHomepage(corpor.getHomepage());
				aWebForm.getCorporPo().setCorporationName(corpor.getCorporationName());
				aWebForm.getCorporPo().setCorporationSynopsis(corpor.getCorporationSynopsis());
				aWebForm.getCorporPo().setEmail(corpor.getEmail());
				aWebForm.getCorporPo().setMobilphone(corpor.getMobilphone());
				aWebForm.getCorporPo().setTelephone(corpor.getTelephone());
				aWebForm.getCorporPo().setCreateDate(format.format(corpor.getCreateDate()));
				request.setAttribute("kind", corpor.getKindId());
				request.setAttribute("vocat", corpor.getVocationId());
				request.setAttribute("addr", corpor.getAddress());

				//企业性质
				str += "var kindId=new Array('','－－请选择性质－－'";
				kindList = sqlmap.queryForList("T_KINDOFCORPORATION.abatorgenerated_selectByExample");
				for(int i=0;i<kindList.size();i++){
					kindPo = (TKindofcorporation)kindList.get(i);
					sKey = kindPo.getId();
					sValue = kindPo.getKindOfName();
					str += ",'" + sKey + "',"; 
					str += "'" + sValue + "'\n";
				}
				str += ");\n";

				//行业列表
				str2 += "var vocation=new Array('','－－请选择行业－－'";
				vocationList = sqlmap.queryForList("T_VOCATION.selectAll");
				for(int i=0;i<vocationList.size();i++){
					vocationPo = (TVocation)vocationList.get(i);
					sKey = vocationPo.getId();
					sValue = vocationPo.getVocationName();
					str2 += ",'" + sKey + "',"; 
					str2 += "'" + sValue + "'\n";
				}
				str2 += ");\n";

				//地区列表
				str3 += "var address=new Array('','－－请选择地区－－'";
				cityList = sqlmap.queryForList("T_CIYT.selectAllCity");
				for(int i=0;i<cityList.size();i++){
					cityPo = (TCiyt)cityList.get(i);
					sKey = cityPo.getId();
					sValue = cityPo.getCityName();
					if((Integer.parseInt(sKey)%100)==0){
						str3 += ",'" + sKey + "',"; 
						str3 += "'" + sValue + "'\n"; 
					}else{
						str3 += ",'" + sKey + "',"; 
						str3 += "'&nbsp;&nbsp;&nbsp;&nbsp;" + sValue + "'\n";
					}
				}
				str3 += ");\n";

				aWebForm.setPrintAddressSql(str3);
				aWebForm.setPrintKindSql(str);
				aWebForm.setPrintVacaSql(str2);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 加载发布浏览
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean viewCorporInfo(HttpServletRequest request,
			HttpServletResponse response,ViewCorporInfoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		ViewCorporInfoBean vBean = new ViewCorporInfoBean();
		TIssuepositionExample positionEp = new TIssuepositionExample();
		List positionList = null;
		TIssueposition issuePoBean = new TIssueposition();
		ArrayList<PositionBean> poBeanList = new ArrayList<PositionBean>();
		try{
			if(request.getParameter("corporId")!="" && request.getParameter("corporId")!=null){
				String corporId = request.getParameter("corporId");
				vBean = (ViewCorporInfoBean)sqlmap.queryForObject("T_CORPORATION.selectViewInfo",corporId);
				aWebForm.setCorporationName(vBean.getCorporationName());
				aWebForm.setKindOfCorpor(vBean.getKindofname());
				aWebForm.setCorporAddress(vBean.getCityname());
				aWebForm.setHomepage(vBean.getHomepage());
				aWebForm.setContactPerson(vBean.getContactPerson());
				aWebForm.setTelephone(vBean.getTelephone());
				aWebForm.setMobilphone(vBean.getMobilphone());
				aWebForm.setContactAddress(vBean.getContactAddress());
				aWebForm.setCorporationSynopsis(vBean.getCorporationSynopsis());

				//职位列表信息
				positionEp.createCriteria().andCORPORATIONEqualTo(corporId);
				positionEp.setOrderByClause(" ISSUETIME desc ");
				positionList = sqlmap.queryForList("T_ISSUEPOSITION.abatorgenerated_selectByExample",positionEp);
				for(int i=0;i<positionList.size();i++){
					PositionBean poBean = new PositionBean();
					issuePoBean = (TIssueposition)positionList.get(i);
					poBean.setPositionId(issuePoBean.getId());
					poBean.setPositionName(issuePoBean.getPOSITION());
					poBean.setIssueTime(format.format(issuePoBean.getSTARTISSUEDATE()));
					poBean.setEndIssueTime(format.format(issuePoBean.getENDISSUEDATE()));
					poBeanList.add(poBean);
				}
				aWebForm.setPositionList(poBeanList);
				result = true;
			}else if(corpor!=null){
				String corporId = corpor.getId();
				vBean = (ViewCorporInfoBean)sqlmap.queryForObject("T_CORPORATION.selectViewInfo",corporId);
				aWebForm.setCorporationName(vBean.getCorporationName());
				aWebForm.setKindOfCorpor(vBean.getKindofname());
				aWebForm.setCorporAddress(vBean.getCityname());
				aWebForm.setHomepage(vBean.getHomepage());
				aWebForm.setContactPerson(vBean.getContactPerson());
				aWebForm.setTelephone(vBean.getTelephone());
				aWebForm.setMobilphone(vBean.getMobilphone());
				aWebForm.setContactAddress(vBean.getContactAddress());
				aWebForm.setCorporationSynopsis(vBean.getCorporationSynopsis());

				//职位列表信息
				positionEp.createCriteria().andCORPORATIONEqualTo(corporId);
				positionEp.setOrderByClause(" ISSUETIME desc ");
				positionList = sqlmap.queryForList("T_ISSUEPOSITION.abatorgenerated_selectByExample",positionEp);
				for(int i=0;i<positionList.size();i++){
					PositionBean poBean = new PositionBean();
					issuePoBean = (TIssueposition)positionList.get(i);
					poBean.setPositionId(issuePoBean.getId());
					poBean.setPositionName(issuePoBean.getPOSITION());
					poBean.setIssueTime(format.format(issuePoBean.getSTARTISSUEDATE()));
					poBean.setEndIssueTime(format.format(issuePoBean.getENDISSUEDATE()));
					poBeanList.add(poBean);
				}
				aWebForm.setPositionList(poBeanList);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	/**
	 * 公司浏览
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean viewCorpor(HttpServletRequest request,
			HttpServletResponse response,ViewCorporInfoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		ViewCorporInfoBean vBean = new ViewCorporInfoBean();
		TIssuepositionExample positionEp = new TIssuepositionExample();
		List positionList = null;
		TIssueposition issuePoBean = new TIssueposition();
		ArrayList<PositionBean> poBeanList = new ArrayList<PositionBean>();
		try{
			if(request.getParameter("corporId")!="" && request.getParameter("corporId")!=null){
				String corporId = request.getParameter("corporId");
				vBean = (ViewCorporInfoBean)sqlmap.queryForObject("T_CORPORATION.selectViewInfo",corporId);
				aWebForm.setCorporationName(vBean.getCorporationName());
				aWebForm.setKindOfCorpor(vBean.getKindofname());
				aWebForm.setCorporAddress(vBean.getCityname());
				aWebForm.setHomepage(vBean.getHomepage());
				aWebForm.setContactPerson(vBean.getContactPerson());
				aWebForm.setTelephone(vBean.getTelephone());
				aWebForm.setMobilphone(vBean.getMobilphone());
				aWebForm.setContactAddress(vBean.getContactAddress());
				aWebForm.setCorporationSynopsis(vBean.getCorporationSynopsis());

				//职位列表信息
				positionEp.createCriteria().andCORPORATIONEqualTo(corporId);
				positionEp.setOrderByClause(" ISSUETIME desc ");
				positionList = sqlmap.queryForList("T_ISSUEPOSITION.abatorgenerated_selectByExample",positionEp);
				for(int i=0;i<positionList.size();i++){
					PositionBean poBean = new PositionBean();
					issuePoBean = (TIssueposition)positionList.get(i);
					poBean.setPositionId(issuePoBean.getId());
					poBean.setPositionName(issuePoBean.getPOSITION());
					poBean.setIssueTime(format.format(issuePoBean.getSTARTISSUEDATE()));
					poBean.setEndIssueTime(format.format(issuePoBean.getENDISSUEDATE()));
					poBeanList.add(poBean);
				}
				aWebForm.setPositionList(poBeanList);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}


	/**
	 * 企业信息修改
	 * @param request
	 * @param response
	 * @param aWebForm
	 * @return
	 * @throws SQLException
	 */
	public static boolean editInfo(HttpServletRequest request,
			HttpServletResponse response,EditInfoForm aWebForm) throws SQLException{
		boolean result = false;
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		TCorporation corpor  = (TCorporation)request.getSession().getAttribute("Corporation");
		TCorporation corpor1 = new TCorporation();
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		try{
			if(corpor !=null){

				corpor1.setId(corpor.getId());
				corpor1.setContactAddress(aWebForm.getCorporPo().getContactAddress());
				corpor1.setContactPerson(aWebForm.getCorporPo().getContactPerson());
				corpor1.setCorporationName(aWebForm.getCorporPo().getCorporationName());
				corpor1.setCorporationSynopsis(request.getParameter("corporContent"));

				if(aWebForm.getCorporPo().getCreateDate()!=null && aWebForm.getCorporPo().getCreateDate()!=""){
					java.util.Date mcreateDate = df.parse(aWebForm.getCorporPo().getCreateDate());
					java.sql.Timestamp createDate =new  java.sql.Timestamp(mcreateDate.getTime());
					corpor1.setCreateDate(createDate);
				}


				corpor1.setAddress(aWebForm.getCorporPo().getAddress());
				corpor1.setEmail(aWebForm.getCorporPo().getEmail());
				corpor1.setTelephone(aWebForm.getCorporPo().getTelephone());
				corpor1.setMobilphone(aWebForm.getCorporPo().getMobilphone());
				corpor1.setHomepage(aWebForm.getCorporPo().getHomepage());
				corpor1.setKindId(aWebForm.getCorporPo().getKindId());
				corpor1.setVocationId(aWebForm.getCorporPo().getVocationId());

				sqlmap.update("T_CORPORATION.abatorgenerated_updateByPrimaryKeySelective", corpor1);
				result = true;
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		return result;
	}

	public static void ajaxForSubPo(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException{
		response.setContentType("text/xml");
		response.setCharacterEncoding("UTF-8");
		String sortId = request.getParameter("selected");
		PrintWriter out = response.getWriter();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		List subStationList = null;
		TSubStation subStationPo = new TSubStation();
		try{
			//生成岗位列表
			subStationList = sqlmap.queryForList("T_SUB_STATION.selectBySortId",sortId);
			out.println("<response>");
			for(int i=0;i<subStationList.size();i++){
				subStationPo = (TSubStation)subStationList.get(i);
				out.println("<substation>");
				out.println("<stationname>"+subStationPo.getPostName()+"</stationname>");
				out.println("<stationvalue>"+subStationPo.getId()+"</stationvalue>");
				out.println("</substation>");
			}
			out.println("</response>");
			out.flush();
			out.close();
		}catch(Exception e){
			e.printStackTrace();
		}

	}
	/**
	 * 求职者列表
	 * @author 
	 *
	 */
	public static void viewUserList(HttpServletRequest request,
			HttpServletResponse response,RegUserInfoForm aWebForm){
		CTurnPage page = new CTurnPage();
		TUserInfo userPo = new TUserInfo();
		try{

			userPo.setEducation(aWebForm.getEducation());
			userPo.setSex(aWebForm.getSex());
			userPo.setSchoolName(aWebForm.getSchoolName());
			userPo.setAgeStart(aWebForm.getAgeStart());
			userPo.setAgeEnd(aWebForm.getAgeEnd());
			userPo.setRegisteredAddress(aWebForm.getRegisteredAddress());
			userPo.setSpeciality(aWebForm.getSpeciality());

			page.setQueryList("T_USER_INFO.selectUserListByCondition",userPo);
			page.setPerPageRows(10);//设置每页行数
			page.excute(request);
			request.setAttribute("page", page);

		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
